#ifndef __TSS_H__
#define __TSS_H__

#define TASKIDLE      0x12000
#define TASKWORMC     0x13000
#define TASKWORMD     0x14000
#define TASKMONDRIANC 0x15000
#define TASKMONDRIAND 0x16000
#define uint unsigned int

typedef struct str_tss {
	unsigned short ptl;
	unsigned short  unused0;
	unsigned int esp0;
	unsigned short  ss0;
	unsigned short  unused1;
	unsigned int esp1;
	unsigned short  ss1;
	unsigned short  unused2;
	unsigned int esp2;
	unsigned short  ss2;
	unsigned short  unused3;
	unsigned int cr3;
	unsigned int eip;
	unsigned int eflags;
	unsigned int eax;
	unsigned int ecx;
	unsigned int edx;
	unsigned int ebx;
	unsigned int esp;
	unsigned int ebp;
	unsigned int esi;
	unsigned int edi;
	unsigned short  es;
	unsigned short  unused4;
	unsigned short  cs;
	unsigned short  unused5;
	unsigned short  ss;
	unsigned short  unused6;
	unsigned short  ds;
	unsigned short  unused7;
	unsigned short  fs;
	unsigned short  unused8;
	unsigned short  gs;
	unsigned short  unused9;
	unsigned short  ldt;
	unsigned short  unused10;
	unsigned short  dtrap;
	unsigned short  iomap;
} __attribute__((__packed__, aligned (8))) tss;


/** Tabla de TSSs **/
extern tss tsss[];
extern tss tarea_inicial;
extern tss tarea_idle;
extern uint TAREA_INICIAL;

void inicializar_tss_desc();
void cargar_tss_desc(uint index, tss* dir_tarea);
void cargar_tss(tss* tarea_tss, uint cr3,uint pila, uint eip);
void duplicar_tss(tss *src, tss *dest, uint cr3);

#define TSS_COUNT 10
#endif //__TSS_H__
